package com.one.producer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Create on 2022-01-17
 * <p>
 * Author: LiangWei
 * <p>
 * Description:
 **/
@Slf4j
@Component
public class RabbitMQTopicProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    /**
     *@author : LiangWei
     *@date : 2022-01-17 17:42
     *@return : void
     *@description : 向指定的交换机发送消息到主题队列中
     */
    public void sendTopicMsg2TopicExchange(String topicExchangeName, String topicRoutingKey, Map<String,Object> topicMap){
        rabbitTemplate.convertAndSend(topicExchangeName,topicRoutingKey,topicMap);
    }

    /**
     *@author : LiangWei
     *@date : 2022-01-19 13:43
     *@return :
     *@description : 发送死信队列绑定的直连队列
     */
    public void sendDead(String deadExchangeName, String deadRoutingName, Map<String,Object> directMap){
        rabbitTemplate.convertAndSend(deadExchangeName,deadRoutingName,directMap);
    }
}
